package sort;

public class QuickSort {

    public static int quickSort(int[] a,int left,int right){
        if(left<right){
            int start,end,value;
            start = left;
            end = right;
            value = a[start];
            while(start<end){
                while (start<end&&a[end]>value)
                    end--;
                if(start<end) {
                    int temp = a[start];
                    a[start] = a[end];
                    a[end] = temp;
                    start++;
                }

                while(start<end&&a[start]<value){
                    start++;
                }

                if(start<end){
                    int temp = a[start];
                    a[start] = a[end];
                    a[end] = temp;
                    end--;
                }

            }
            return end;
        }
        return -1;

    }
}
